import { Body, Controller, Get, Post, Req, Res } from '@nestjs/common';
import { AppService } from './app.service';
import { Response } from 'express';
@Controller('/xunfei')
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Post()
  start(@Body() req, @Res() res: Response) {
    res.setHeader('Content-Type', 'text/event-stream');
    res.setHeader('Cache-Control', 'no-cache');
    res.setHeader('Connection', 'keep-alive');
    this.appService.connectToSpeechAPI(req.text, res);
  }

  @Post('/personStart')
  startPeron() {
    return this.appService.startPerson();
  }

  @Post('/personStop')
  stopPeron() {
    return this.appService.stopPerson();
  }
}
